<template>
<div class="pre-order-chart">
<h2 style="text-align: center">笔记本电脑预购情况柱状图</h2>
<div ref="chart" style="width: 100%; height: 500px;"></div>
</div>
</template>

<script>
import * as echarts from 'echarts';

export default {
name: 'PreOrderChart',
mounted() {
this.renderChart();
},
methods: {
renderChart() {
const chartDom = this.$refs.chart;
const myChart = echarts.init(chartDom);
const option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
},
xAxis: {
type: 'category',
data: ['戴尔G15', '天选3', '外星人', '华硕', '绿标'],
},
yAxis: {
type: 'value',
},
series: [
{
name: '数量',
type: 'bar',
data: [4, 6, 2, 8, 3],
},
],
};
myChart.setOption(option);
},
},
};
</script>

<style scoped>
.pre-order-chart {
margin: 20px auto;
width: 80%;
height: 600px;
}
</style>